$(function() {
	alterVisitorImg($("#currentVisitorId").val());
	initDetails($("#currentVisitorId").val());
});
function alterVisitorImg(visitorId){
	$.ajax({
		url:rootPath+"/ui/visitorReward/findMe/"+visitorId,
		dataType:'json',
		type:'GET',
		success:function(result){
			var user=result.data.visitor;
			if(user.pictureAddress==undefined||user.pictureAddress==''){
				$("#visitorImg").attr("src","/wcsi/img/vistor.jpg");
			}else{
				$("#visitorImg").attr("src",rootPath+"/"+user.pictureAddress);
			}
		}
	})
};
function initDetails(visitorId){
	
	$.ajax({
		url:rootPath+"/ui/visitorReward/findMyDetails/"+visitorId,
		dataType:'json',
		type:'GET',
		success:function(result){
			var str="#myRewardDetails";
			var list=result.data.rewards;
			if (list.length == 0) {
				var contenthtml = '<li><h2 style="color:blue">暂无获奖信息</h2></li>';
				$(str).append(contenthtml);
				$(str).listview('refresh');
			}
			
			$.each(list,function(){
				//var contenthtml = "<li><div>获得分值:"+this.rewardValue+"</div><div>奖励时间:"+moment(this.createTime).format("YYYY/MM/DD HH:mm")+"</div><div>所属事件:"+this.register.registerEventName+"</div></li>";
				var contenthtml='<br/><div class="div1">'
					+'<a data-transition="slide"><div class="div-time"><div style="margin-left:20px;">'
					+moment(this.createTime).format("YYYY/MM/DD HH:mm")
					+'</div></div></a><br/>'
				    +'<div class="div-type">获得分值:'+this.rewardValue+'</div><div class="div-type">所属事件:'+this.register.registerEventName+'</div><br/>';
					+'</div>';
				$(str).append(contenthtml);
				$(str).listview('refresh');
			});
			
		}
	});
}